package com.example.demo.Controller;

import com.example.demo.Dao.AddressRepository;
import com.example.demo.Dao.RecordRepository;
import com.example.demo.Entity.Address;
import com.example.demo.Entity.Record;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.nio.file.AccessDeniedException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 *
 * 	住户出入数据统计模块
 * 	住户健康信息数据统计模块
 *  所有列表可以进行综合查询，特别是时间字段，并可以排序；
 * 	所有列表可以导出excel文件或pdf文件；
 * 	住户健康状态智能预警模块
 * */
@RestController
@RequestMapping("/Record")
public class RecordController {

    @Autowired
    private RecordRepository recordRepository;

    @Autowired
    private AddressRepository addressRepository;

    @RequestMapping("/a")
    @ResponseBody
    public List<Address> test () {
        List<Address> list = new ArrayList<Address>();
        list = addressRepository.findAll();
        return list;
    }

    @RequestMapping("/AllRecord")
    @ResponseBody
    public List<Record> findAll() {
        List<Record> list = new ArrayList<Record>();
        list = recordRepository.findAll();
        return list;
    }

    @RequestMapping("/temperature")
    @ResponseBody
    public List<Record> findAllBytime(String temperature){
        List<Record> record = (List<Record>) recordRepository.findAllByTemperature(temperature);
        return record;
    }
}
